// 导入接口
import {getVad,loginIt} from '../api/user'
import {useEffect,useState} from 'react'
function Login() {
  const [vad,setVad]  = useState('');
  const [loginData,setLoginData] = useState({
    username:'wuxw',
    passwd:'admin',
    logo:'HC',
    validateCode:'',
    errorInfo:'',
  })
  useEffect(()=>{
    getVad().then(res=>{      
      setVad(res.data)
    })
  },[])
  function toLogin(){
    loginIt(loginData).then(res=>{
      console.log(res.data,"res",res)
      if(res.data){
        location.href="#/admin"
      }
    })
    
  }
  return ( <div>登录
    <img src={vad} alt=""/>
    <input value={loginData.validateCode} onChange={(e)=>{
      setLoginData({
        ...loginData,
        validateCode:e.target.value
      })
    }}/>
    <button onClick={toLogin}>登录</button>

  </div> );
}

export default Login;